<template>
    <div class="section">
        <div class="swiper-container"
             ref="slider">
            <div class="swiper-wrapper">
                <div v-for="s in sliders" class="swiper-slide">
                    <img :src="s.img_url"/>
                </div>
            </div>
            <div class="swiper-pagination"
                 ref="pagination">
            </div>
        </div>
        <div class="announcement">
            <label>快讯</label>
            <span>{{announcement}}</span>
        </div>
    </div>
</template>
<script type="text/ecmascript-6">
    import Swiper from "swiper"
    import 'swiper/dist/css/swiper.css'
    export default{
        props: ["announcement", "sliders"],
        beforeMounted(){
          console.log("slider beforeMounted");
        },
        beforeCreate(){
            console.log("slider beforeCreate");
        },
        create(){
          console.log("slider create");
        },
        mounted() {
            window.setTimeout(function() {
                console.log('slider setTimeout');
                new Swiper('.swiper-container', {
                    pagination:".swiper-pagination",
                    paginationClickable: true,
                    spaceBetween: 30,
                    centeredSlides: true,
                    autoplay: 2500,
                    autoplayDisableOnInteraction: false
                })
            },1000);
            console.log("slider mounted");
        }
    }
</script>
<style>
    .announcement {
        font-size: 12px;
        padding: 5px;
        background: #fff;
    }

    .announcement > label {
        padding: 3px 10px;
        margin: 3px 10px;
        background: #FACCB7;
        border-radius: 3px;
        color: #FF5102;
    }

    .announcement > span {
        padding: 3px 10px;
        color: #333;
        display: inline-block;
    }

    .swiper-container {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .swiper-wrapper {
        height: 200px;
    }

    .swiper-slide img {
        max-width: 100%;
    }

    .swiper-slide {
        text-align: center;
        background: #fff;
        /* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
    }
</style>